﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data;
using System.Web.UI.WebControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
    Funtion_TT fu = new Funtion_TT();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            set();
        }
        DataTable dt = new DataTable();
        dt = fu.getSanPhamNew();
        DataList1.DataSource = dt;
        DataList1.DataBind();
    }
    protected void set()
    {
        if (Session["login"] == null)
        {
            MultiView1.ActiveViewIndex = 0;
        }
        else
        {
            MultiView1.ActiveViewIndex = 1;
        }   
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string tk = TextBox1.Text;
        string mk = TextBox2.Text;
        int check = fu.CheckLoginNguoiDung(tk, mk);
        if (check == 1 )
        {
            Session["login"] = tk;
        }
        else
        {
            Response.Write("<script language='JavaScript'> alert('Sai tài khoản hoặc mật khẩu !!'); </script>");
        }
        set();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Session["login"] = null;
        set();
    }
}
